﻿using Microsoft.AspNetCore.Mvc;
using SmartAnswerPlatform.Models.Enum;
using SmartAnswerPlatform.Models.ViewModels;
using System.Net.NetworkInformation;

namespace SmartAnswerPlatform.WebApi.Controllers
{
    public class BaseController : ControllerBase
    {

        [NonAction]
        public JsonResult Success(object? data = null, string? msg = null)
        {
            ApiResult apiResult = new ApiResult()
            {
                Code = ApiStatus.OK,
                Msg = msg ?? "OK",
                Data = data
            };
            return new JsonResult(apiResult);
        }
        [NonAction]
        public JsonResult Fail(string? msg = null)
        {
            ApiResult apiResult = new ApiResult()
            {
                Code = ApiStatus.Fail,
                Msg = msg ?? "OK",
            };
            return new JsonResult(apiResult);
        }
        [NonAction]
        public JsonResult Error(string? msg = null)
        {
            ApiResult apiResult = new ApiResult()
            {
                Code = ApiStatus.Error,
                Msg = msg ?? "OK",
            };
            return new JsonResult(apiResult);
        }
    }
}
